﻿<?php
	if(!empty($_POST)){
		require_once("../config/config.php");

	$nom    = $_POST["nom"];
	$prenom = $_POST["prenom"];
	$mail   = $_POST["mail"];
	$statut = $_POST["statut"];
	$banque = $_POST["banque"];
	$agence = $_POST["agence"];  
	$compte = $_POST["compte"];
	$cle    = $_POST["cle"];
	
	echo "$nom, $prenom, $mail, $statut, $banque, $agence, $compte, $cle";
	
	//connexion à la base de donnée via PDO
	$db = new PDO(PDO_DSN, USER , PASSWD ) or die("échec de connexion au serveur");
	$db->exec("SET NAMES 'UTF8'");
	
	$sql="INSERT INTO clients(cl_id, cl_nom, cl_prenom, cl_mail, cli_status, 
			rib_banque, rib_agence, rib_cpte, rib_cle)
		  VALUES((select max(cl_id)+1 from clients),'$nom','$prenom','$mail','$statut',
				  $banque, $agence, $compte, $cle)";
	$rq=$db->prepare($sql);
	$rq->execute();
		
	} 
	
	header("location: ../pages/listeClients.php");
	
?>